<?php
/*
 * 订餐系统(装饰模式)
 * ----------------------------
 * 可以点饮料，如咖啡、茶
 * 可以在饮料中加调味料，如糖、牛奶
 * 点完后返回价钱
 * ----------------------------
 * @author    Leo
 * @filename run.php
 * @Created  2015/10/4 1:41
 */


//自动加载
spl_autoload_register(function($class){
	$path = './Service/'.$class.'.php';
	if(!file_exists($path)){
		$path = './Service/Condiment/'.$class.'.php';
	}
	require $path;
});


$coffee = new Coffee();

$coffee = new Milk($coffee);
$coffee = new Sugar($coffee);

echo '饮料名: '.$coffee->getName().PHP_EOL;
echo '价钱: ' .$coffee->cost().PHP_EOL;